#include "widget.h"
#include "ui_widget.h"
#include<QTableWidget>
#include<QTableWidgetItem>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->tableWidget->insertRow(0);
    ui->tableWidget->insertRow(1);
    ui->tableWidget->insertRow(2);

    ui->tableWidget->insertColumn(0);
    ui->tableWidget->insertColumn(1);
    ui->tableWidget->insertColumn(2);

    QTableWidgetItem* item1=new QTableWidgetItem("星期一");
    item1->setIcon(QIcon(":/week.png"));
    ui->tableWidget->setHorizontalHeaderItem(0,item1);

    QTableWidgetItem* item2=new QTableWidgetItem("星期二");
    item2->setIcon(QIcon(":/week.png"));
    ui->tableWidget->setHorizontalHeaderItem(1,item2);

    QTableWidgetItem* item3=new QTableWidgetItem("星期三");
    item3->setIcon(QIcon(":/week.png"));
    ui->tableWidget->setHorizontalHeaderItem(2,item3);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_addrow_clicked()
{
    int row=ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(row);
}

void Widget::on_pushButton_deleterow_clicked()
{
    int row=ui->tableWidget->currentRow();
    ui->tableWidget->removeRow(row);
}

void Widget::on_pushButton_addcolumn_clicked()
{
    QString text=ui->lineEdit->text();
    QTableWidgetItem* item=new QTableWidgetItem(text);
    item->setIcon(QIcon(":/week.png"));
    int column=ui->tableWidget->columnCount();
    ui->tableWidget->insertColumn(column);
    ui->tableWidget->setHorizontalHeaderItem(column,item);
}

void Widget::on_pushButton_deletecolumn_clicked()
{
    int column=ui->tableWidget->currentColumn();
    ui->tableWidget->removeColumn(column);
}
